/**
 * @author DongPing
 * 2022/1/11 19:48
 *
 * 收款池、扣款池 认领页面的认领明细组件
 *
 * */
import {CollectionBusiness} from "@/biz-components/claim-items/collection-business";
import {CollectionBusinessNotClean} from "@/biz-components/claim-items/collection-business-not-clean";
import {CollectionFinance} from "@/biz-components/claim-items/collection-finance";
import {CollectionManual} from "@/biz-components/claim-items/collection-manual";
import {DeductBusiness} from "@/biz-components/claim-items/deduct-business";
import {DeductFinance} from "@/biz-components/claim-items/deduct-finance";
import {useField} from "@formily/react";
import {Field} from "@formily/core/lib/models";
import {ClaimItemsScene} from './ClaimItemsScene';
import {CollectionBusinessInstruct} from "@/biz-components/claim-items/collection-business-instruct";
import './filter-style.less';

export {ClaimItemsScene} from './ClaimItemsScene';
export function ClaimItems(props: {
	value: any[],
	onChange: (value: any[]) => void,

	// 认领总共有6种情况，这个参数用来区别这几种场景
	usage: ClaimItemsScene,

	// 收款类型, 收款池财务认领的时候需要通过这个参数控制表格列的显示与隐藏
	collectionType: string,

	// 认领门店
	shop: string,

	// 认领对象
	claimTarget: string,
	// 匹配性质 用来查询认领明细
	matchType: string,

	// 扣款类型
	deductType: string,

	// 收款明细事项，首款池-业务认领的时候 查询未清项数据
	collectionDetailItemType: string,

	// 是否显示开票金额
	showInvoiceAmount: boolean,

	// 费用类型 扣款池业务认领查询认领明细用
	rbrsType: string,
	// 还本类型 扣款池业务认领查询明细用
	repymtType: string,

}) {
	const {usage = ClaimItemsScene.collection_business, collectionType = '', shop = '', deductType = '', claimTarget = '', collectionDetailItemType = '', rbrsType = '', repymtType = ''} = props;
	const f = useField<Field>();
	let validateError = f.validateStatus === 'error';

	let result: any;

	switch (usage) {
		case ClaimItemsScene.collection_business:
			result = <CollectionBusiness matchType={props.matchType} value={props.value} onChange={props.onChange} shopCode={shop} claimTarget={claimTarget}/>;
			break;
		case ClaimItemsScene.collection_not_clean:
			result = <CollectionBusinessNotClean collectionType={collectionType} shop={shop} matchType={props.matchType} claimTarget={claimTarget} collectionDetailItemType={collectionDetailItemType} value={props.value} onChange={props.onChange}/>;
			break;
		case ClaimItemsScene.collection_business_instruct:
			// @ts-ignore
			result = <CollectionBusinessInstruct {...props}/>;
			//result = null;
			break;
		case ClaimItemsScene.collection_finance:
			result = <CollectionFinance validateError={validateError} shop={shop} value={props.value} onChange={props.onChange} collectionType={collectionType}/>;
			break;
		case ClaimItemsScene.collection_manual:
			result = <CollectionManual validateError={validateError} value={props.value} onChange={props.onChange} shop={shop}/>;
			break;
		case ClaimItemsScene.deduct_business:
			result = <DeductBusiness matchType={props.matchType} rbrsType={rbrsType} repymtType={repymtType} value={props.value} onChange={props.onChange} claimTarget={claimTarget} shop={shop}/>;
			break;
		case ClaimItemsScene.deduct_finance:
			result = <DeductFinance showInvoiceAmount={props.showInvoiceAmount} deductType={deductType} shop={shop} value={props.value} onChange={props.onChange}/>;
			break;
		default:
			result = null
	}
	return (

			result

	)
}
